package com.makenv.service;

import com.makenv.dao.VideoMapper;
import com.makenv.domain.Video;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoService {

    @Autowired
    VideoMapper videoMapper;

    public int insert(String name, String author, String description, String link, String category) {

        Video video = new Video();
        video.setName(name);
        video.setAuthor(author);
        video.setDescription(description);
        video.setLink(link);
        video.setCategory(category);
        return videoMapper.insert(video);
    }

    public int getVideoSum() {
        return videoMapper.getVideoSum();
    }

    public int getSearchVideoSum(String bookName) {
        return videoMapper.getSearchVideoSum(bookName);
    }

    public List<Video> showVideoList(int startRow, int num, String bookName) {
        return videoMapper.showVideoList(startRow, num, bookName);
    }

    public int deleteByPrimaryKey(int id) {
        return videoMapper.deleteByPrimaryKey(id);
    }

    public int updateByPrimaryKey(int id, String name, String author, String description, String link, String category) {

        Video video = new Video();
        video.setId(id);
        video.setName(name);
        video.setAuthor(author);
        video.setDescription(description);
        video.setLink(link);
        video.setCategory(category);
        return videoMapper.updateByPrimaryKey(video);
    }
}
